<?php

namespace app\controllers;

use app\logic\RoleLogic;
use yii\web\HttpException;
use app\components\Controller;

/**
 * 角色
 */
class RoleController extends Controller
{
    protected function verbs()
    {
        return [
            'index' => ['GET'],
            'create' => ['POST'],
            'update' => ['POST'],
            'delete' => ['GET'],
            'disable' => ['GET'],
            'enable' => ['GET'],
            'get-info' => ['GET'],
            'get-default' => ['GET'],
        ];
    }

    /**
     * 首页
     * @return array
     * @throws HttpException
     */
    public function actionIndex()
    {
        return RoleLogic::getList(getParams());
    }

    /**
     * Notes:创建
     * Date: 2020/7/27
     * Time: 14:29
     * @throws HttpException
     * @throws \yii\db\Exception
     */
    public function actionCreate()
    {
        return RoleLogic::create(getParams());
    }

    /**
     * 编辑
     * @throws HttpException
     */
    public function actionUpdate()
    {
        return RoleLogic::update(getParams());
    }

    /**
     * 删除
     * @throws HttpException
     * @throws \Throwable
     */
    public function actionDelete()
    {
        return RoleLogic::delete(getParams());
    }

    /**
     * 角色状态
     * @throws HttpException
     */
    public function actionStatus()
    {
        return RoleLogic::status(getParams());
    }


    /**
     * 授权项下部门授权的数据
     * @return array|mixed
     * @throws HttpException
     */
    public function actionGetItemData()
    {
        return RoleLogic::getItemData(getParams());
    }

    /**
     * 权限项信息、编辑表单
     * @return array
     * @throws HttpException
     */
    public function actionGetInfo()
    {
        return RoleLogic::getInfo(getParams());
    }

    /**
     * 默认权限项
     * @return array
     * @throws HttpException
     */
    public function actionGetDefaultItem()
    {
        return RoleLogic::getDefaultItem(getParams());
    }
}
